package com.neusoft.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.mapper.EmpInfoMapper;
import com.neusoft.service.EmpInfoService;
import com.neusoft.vo.EmpInfoResultVO;

@Service
public class EmpInfoServiceImpl implements EmpInfoService {

	@Autowired
	private EmpInfoMapper mapper;

	@Transactional(propagation = Propagation.SUPPORTS)
	@Override
	public EmpInfoResultVO getEmpInfo(Integer empno) {

		// 创建员工个人信息实例
		EmpInfoResultVO vo = new EmpInfoResultVO();

		// 获取基本信息
		vo = mapper.getEmpInfo(empno);
		if(vo == null) {
			vo = mapper.getEmpLessInfo(empno);
		}
		System.out.println(vo);

		// 获取部门履历信息
		if (mapper.getDeptHistory(empno) != null && !mapper.getDeptHistory(empno).isEmpty()) {
			vo.setDeptHistory(mapper.getDeptHistory(empno));
		}

		// 获取职位履历信息
		if (mapper.getJobHistory(empno) != null && !mapper.getJobHistory(empno).isEmpty()) {
			vo.setJobHistory(mapper.getJobHistory(empno));
		}

		// 返回员工个人信息
		return vo;
	}

}
